<template>
	<view class="login-container">
		<view class="login-header">
			<image src="/static/logo.png" mode="aspectFit" class="logo"></image>
			<text class="app-name">智慧教育</text>
			<text class="welcome-text">欢迎回来</text>
		</view>
		
		<view class="login-form">
			<view class="input-group">
				<view class="input-item">
					<text class="iconfont icon-user"></text>
					<input type="text" v-model="username" placeholder="请输入用户名/手机号" />
				</view>
				<view class="input-item">
					<text class="iconfont icon-lock"></text>
					<input type="password" v-model="password" placeholder="请输入密码" />
				</view>
			</view>
			
			<view class="options-group">
				<label class="remember-me">
					<checkbox :checked="rememberMe" @tap="rememberMe = !rememberMe" color="#007AFF" />
					<text>记住我</text>
				</label>
				<text class="forgot-password" @tap="navigateTo('/pages/forgot-password/forgot-password')">忘记密码？</text>
			</view>
			
			<button class="login-btn" @tap="handleLogin">登录</button>
			
			<view class="other-login">
				<view class="divider">
					<view class="line"></view>
					<text>其他登录方式</text>
					<view class="line"></view>
				</view>
				<view class="social-login">
					<view class="social-item" @tap="handleSocialLogin('wechat')">
						<image src="/static/icon/wechat.png" mode="aspectFit"></image>
					</view>
					<view class="social-item" @tap="handleSocialLogin('qq')">
						<image src="/static/icon/qq.png" mode="aspectFit"></image>
					</view>
					<view class="social-item" @tap="handleSocialLogin('weibo')">
						<image src="/static/icon/weibo.png" mode="aspectFit"></image>
					</view>
				</view>
			</view>
		</view>
		
		<view class="register-link">
			<text>还没有账号？</text>
			<text class="link" @tap="navigateTo('/pages/register/register')">立即注册</text>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue';

const username = ref('');
const password = ref('');
const rememberMe = ref(false);

function handleLogin() {
	if (!username.value || !password.value) {
		uni.showToast({
			title: '请输入用户名和密码',
			icon: 'none'
		});
		return;
	}
	
	// TODO: 实现登录逻辑
	uni.showLoading({
		title: '登录中...'
	});
	
	// 模拟登录请求
	setTimeout(() => {
		uni.hideLoading();
		uni.switchTab({
			url: '/pages/index/index'
		});
	}, 1500);
}

function handleSocialLogin(type) {
	uni.showToast({
		title: `${type}登录功能开发中`,
		icon: 'none'
	});
}

function navigateTo(url) {
	uni.navigateTo({
		url: url
	});
}
</script>

<style>
.login-container {
	min-height: 100vh;
	padding: 60rpx 40rpx;
	background-color: #FFFFFF;
	display: flex;
	flex-direction: column;
}

.login-header {
	display: flex;
	flex-direction: column;
	align-items: center;
	margin-bottom: 80rpx;
}

.logo {
	width: 160rpx;
	height: 160rpx;
	margin-bottom: 20rpx;
}

.app-name {
	font-size: 48rpx;
	font-weight: bold;
	color: #333333;
	margin-bottom: 16rpx;
}

.welcome-text {
	font-size: 32rpx;
	color: #666666;
}

.login-form {
	flex: 1;
}

.input-group {
	margin-bottom: 40rpx;
}

.input-item {
	display: flex;
	align-items: center;
	height: 100rpx;
	background-color: #F8F9FA;
	border-radius: 50rpx;
	padding: 0 40rpx;
	margin-bottom: 30rpx;
}

.input-item .iconfont {
	font-size: 40rpx;
	color: #999999;
	margin-right: 20rpx;
}

.input-item input {
	flex: 1;
	height: 100%;
	font-size: 28rpx;
}

.options-group {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 60rpx;
}

.remember-me {
	display: flex;
	align-items: center;
}

.remember-me text {
	font-size: 26rpx;
	color: #666666;
	margin-left: 8rpx;
}

.forgot-password {
	font-size: 26rpx;
	color: #007AFF;
}

.login-btn {
	width: 100%;
	height: 90rpx;
	background-color: #007AFF;
	color: #FFFFFF;
	font-size: 32rpx;
	border-radius: 45rpx;
	margin-bottom: 60rpx;
}

.other-login {
	margin-bottom: 60rpx;
}

.divider {
	display: flex;
	align-items: center;
	margin-bottom: 40rpx;
}

.line {
	flex: 1;
	height: 1px;
	background-color: #EEEEEE;
}

.divider text {
	font-size: 26rpx;
	color: #999999;
	padding: 0 30rpx;
}

.social-login {
	display: flex;
	justify-content: center;
	gap: 80rpx;
}

.social-item {
	width: 80rpx;
	height: 80rpx;
}

.social-item image {
	width: 100%;
	height: 100%;
}

.register-link {
	text-align: center;
	font-size: 28rpx;
	color: #666666;
}

.register-link .link {
	color: #007AFF;
	margin-left: 10rpx;
}
</style> 